# -*- coding: utf-8 -*-
'''
模块：生意通-经营数据-经营概况
输入：cookie,hotel_id,hotel_name
输出：SeqNo # 城市排名
      SeqNo2  # 竟争圈排名
'''
import requests
import json
from fcs import url_request

def main(cookies,hotel_id,hotel_name):
    item={}
    url="http://syt.ctrip.com/api/biddingajax/queryRankHotelSeqInfoCityAndCompetitor?hostType=Ebooking"
    header={
        'Content-Type':'application/json'
    }

    # con=requests.post(url=url,cookies=cookies,headers=header).text

    while True:
        try:
            con=url_request.post_url_requests(url=url,cookies=cookies,headers=header,data={})
            json_data = json.loads(con)['ModelList']
            break
        except:
            continue

    # json_data=json.loads(con)['ModelList']
    try:
        SeqNo=json_data[0]['List'][9]['SeqNo']
        SeqNo2=json_data[1]['List'][9]['SeqNo']
    except:
        SeqNo=''
        SeqNo2=''
    item.update(SeqNo=SeqNo)
    item.update(SeqNo2=SeqNo2)
    return item